home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / viewkit / xcontact / include / ListView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  6.9 KB  |  226 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. ///////////////////////////////////////////////////////////////////// 
  18. // ListView.h --
  19. /////////////////////////////////////////////////////////////////////
  20. #ifndef LISTVIEW_H
  21. #define LISTVIEW_H
  22.  
  23. #include "Buttons.h"
  24. #include "Print.h"
  25. #include "GeneralPrefs.h"
  26. #include "Database.h"
  27.  
  28. #include "OkLabeledComponent.h"
  29. #include "OkLabel.h"
  30. #include "OkText.h"
  31. #include "OkStrArray.h"
  32.  
  33.  
  34. #include <Vk/VkWindow.h>
  35. #include <Vk/VkMenu.h>
  36. #include <Vk/VkApp.h>
  37.  
  38.  
  39. #define MAX_CARD_VIEWS 8
  40. #define NO_ACTIVE_VIEWER -1
  41.  
  42.  
  43. class CardView;
  44. class CardInfo;
  45. class CardList;
  46. class OkFile;
  47. class ShowBtn;
  48. class DeleteBtn;
  49. class NewBtn;
  50. class ExportImportDialog;
  51.  
  52. class ListView : public VkWindow {
  53.  
  54.  public:
  55.   ListView();
  56.   ~ListView();
  57.   const char* className() { return "ListView"; }
  58.  
  59.   void showRolodexNameInTitle( const char* dbName );
  60.   Boolean okToQuit();
  61.  
  62.   void setupFields();
  63.   void setupAttributes();
  64.  
  65.   OkText* srchText()         { return _srchText->component(); }
  66.   CardList* cardList()         { return _cardList; }
  67.  
  68.   void updateCardListFromCardInfo( unsigned pos, const CardInfo* cInfo );
  69.   void updateCardListFromDb( const char* busyMsg=NULL );
  70.  
  71.   void setCardSensitivity();
  72.   void setMenuAndBtnSensitivity();
  73.   void updateIndicatorLabel( int cardNo=0 );
  74.  
  75.   void showCard( unsigned pos, CardInfo* cInfo=NULL );
  76.   unsigned addCard( VkSimpleWindow* win=NULL );
  77.   unsigned addCard( const char* name, CardInfo** );
  78.   Boolean deleteCard( unsigned pos );
  79.   Boolean deleteCard( unsigned pos, CardInfo* cInfo, VkSimpleWindow* win=NULL );
  80.  
  81.   int currCardNo() const    { return _currCardNo; }
  82.   int totalCards() const;
  83.  
  84.  
  85.   ///////////////////////////////
  86.   // Viewer manipulations.
  87.   ///////////////////////////////
  88.   void closeAllCardViews();
  89.   int activeCardViewer() { return _activeCardViewer; }
  90.   void setNoActiveCardViewer();
  91.   void setActiveCardViewer( CardView*  );
  92.   void setActiveCardViewer( int n ) 
  93.         { setActiveCardViewer( _cardViewTable[ n ] ); }
  94.   Boolean noActiveCardViewer() const 
  95.         { return (_activeCardViewer==NO_ACTIVE_VIEWER); }
  96.  
  97.   void resetCardViewTableEntry( int i ) 
  98.         { _cardViewTable[ i ] = NULL; }
  99.   void saveAllCardViewChanges();
  100.  
  101.   void openFile( const char* fileName=NULL, Boolean openNew=FALSE );
  102.   void save();
  103.   void deleteAll();
  104.  
  105.  protected:
  106.   void handleWmDeleteMessage() { quitCB( NULL, NULL, NULL ); }
  107.  
  108.  private:
  109.   
  110.   static VkMenuDesc mainMenuPane[];
  111.   static VkMenuDesc fileMenuPane[];
  112.   static VkMenuDesc cardMenuPane[];
  113.   static VkMenuDesc prefsMenuPane[];
  114.   static VkMenuDesc sortMenuPane[];
  115.  
  116.   // General Preference dialog.
  117.   GeneralPrefDialog*    _generalPrefDialog;
  118.  
  119.   // Export Import dialog.
  120.   ExportImportDialog*    _exportImportDialog;
  121.  
  122.   //////////////////////////////////////////////////////
  123.   // Viewer Table.
  124.   //////////////////////////////////////////////////////
  125.   CardView*        _cardViewTable[ MAX_CARD_VIEWS ];
  126.   int            _activeCardViewer;
  127.  
  128.   OkLabeledComponent<OkText>*    _srchText;
  129.   CardList*        _cardList;
  130.  
  131.   ShowBtn*        _showBtn;
  132.   DeleteBtn*        _deleteBtn;
  133.   NewBtn*        _newBtn;
  134.  
  135.   int            _currCardNo;
  136.  
  137.   Widget        _indicatorLabel;
  138.  
  139.   OkLabel*        _listHeader;
  140.  
  141.  
  142.   /////////////////////////////////////////////////////////////////
  143.   // Callbacks.
  144.   /////////////////////////////////////////////////////////////////
  145.   // File menu:
  146.   static void newFileCB( Widget, XtPointer obj, XtPointer )
  147.             { ((ListView *)obj)->openFile( "", TRUE ); }    
  148.   static void openFileCB( Widget, XtPointer obj, XtPointer )
  149.             { ((ListView *)obj)->openFile(); }    
  150.   static void saveCB( Widget, XtPointer obj, XtPointer )
  151.             { ((ListView *)obj)->save(); }    
  152.   static void saveAsCB( Widget, XtPointer, XtPointer );
  153.  
  154.   static void importCB( Widget, XtPointer obj, XtPointer )
  155.             { ((ListView *)obj)->import(); }
  156.   static void exportCB( Widget, XtPointer obj, XtPointer )
  157.             { ((ListView *)obj)->export(); }
  158.  
  159.   static void printAllCB( Widget, XtPointer, XtPointer )
  160.             { thePrintCardDialog->printCardView(); }
  161.   static void quitCB( Widget, XtPointer, XtPointer )
  162.             { theApplication->quitYourself(); }
  163.  
  164.   // Card menu:
  165.   static void searchCB( Widget, XtPointer, XtPointer );
  166.   static void showCB( Widget, XtPointer obj, XtPointer )
  167.             { ((ListView *)obj)->_showBtn->activate(); }    
  168.   static void deleteCB( Widget, XtPointer obj, XtPointer ) 
  169.             { ((ListView *)obj)->_deleteBtn->activate(); }    
  170.   static void deleteAllCB( Widget, XtPointer obj, XtPointer ) 
  171.             { ((ListView *)obj)->deleteAll(); }    
  172.   static void newCB( Widget, XtPointer obj, XtPointer )
  173.             { ((ListView *)obj)->_newBtn->activate(); }    
  174. //  static void printCB( Widget, XtPointer obj, XtPointer ) {}
  175.   static void closeAllCardViewsCB( Widget, XtPointer obj, XtPointer )
  176.             { ((ListView *)obj)->closeAllCardViews(); }    
  177.  
  178.   // Preferences menu:
  179.   static void setupFieldsCB( Widget,XtPointer obj,XtPointer )
  180.             { ((ListView *)obj)->setupFields(); }
  181.   static void setupAttributesCB( Widget, XtPointer obj, XtPointer ) 
  182.             { ((ListView *)obj)->setupAttributes(); }
  183.  
  184.   static void sortAscendingCB( Widget, XtPointer obj, XtPointer )
  185.             { ((ListView *)obj)->sort( ASCENDING ); }
  186.   static void sortDescendingCB( Widget, XtPointer obj, XtPointer )
  187.             { ((ListView *)obj)->sort( DESCENDING ); }
  188.  
  189.   static void generalCB( Widget, XtPointer obj, XtPointer ) 
  190.             { ((ListView *)obj)->_generalPrefDialog->post(); }    
  191.  
  192.   // Keyboard callback.
  193.   void checkEscKeyPress( XKeyEvent*, Boolean* b );
  194.   static void checkEscKeyPressCB( Widget, XtPointer obj, XEvent* e, Boolean *b )
  195.     { ((ListView *)obj)->
  196.     checkEscKeyPress( (XKeyEvent*) e, b ); }
  197.  
  198.   /////////////////////////////////////////////////////////////////
  199.   // Vk Callbacks.
  200.   /////////////////////////////////////////////////////////////////
  201.   void setAttrPrefChanged( VkComponent *dialog, void*, void* reason );
  202.   void setAttrPrefChangedView( CardView* );
  203.   void generalPrefChanged( VkComponent *dialog, void*, void* reason );
  204.  
  205.  
  206.   /////////////////////////////////////////////////////////////////
  207.   // Utility Funcs.
  208.   /////////////////////////////////////////////////////////////////
  209.   void export();
  210.   void import();
  211.   void sort( SortOrder );
  212.  
  213.   enum AdjustReason { ADD, DELETE };
  214.   void adjustViewerCardPos( unsigned, AdjustReason );
  215.  
  216.   VkDialogManager::VkDialogReason openFileDialog( OkStr& fileName, 
  217.                     const char* dialogTitle=NULL );
  218.  
  219. };
  220.  
  221.  
  222. // This is the one and only ListView for the whole app.
  223. extern ListView* theListView;
  224.  
  225. #endif
  226.